package docoffice.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class SysAdminPanel extends JPanel {
	
	private final JLabel sysTitle, blank;
	
	private final JButton createPatient, deletePatient, viewPatient, viewAppt;
	
	private final JButton addUser, editUser, accountLock;

	public SysAdminPanel() {
		sysTitle = new JLabel("System Administrator Login");
		blank = new JLabel();
		createPatient = new JButton("Create New Patient");
		deletePatient = new JButton("Delete a Patient");
		viewPatient = new JButton("Patient Lookup");
		viewAppt = new JButton("View Appointments");
		
		addUser = new JButton("Add New User");
		editUser = new JButton("Edit/Delete Existing User");
		accountLock = new JButton("Lock/Unlock User");
		
		createPatient.addActionListener(new CreateListener());
		deletePatient.addActionListener(new DeleteListener());
		viewPatient.addActionListener(new ViewPatientListener());
		viewAppt.addActionListener(new ViewApptListener());
		addUser.addActionListener(new AddListener());
		editUser.addActionListener(new EditListener());
		accountLock.addActionListener(new AccountListener());
		
		setLayout(new GridLayout(5, 2, 15, 10));
		add(sysTitle);
		add(blank);
		add(createPatient);
		add(deletePatient);
		add(viewAppt);
		add(addUser);
		add(editUser);
		add(accountLock);
		
		setPreferredSize(new Dimension(500, 400));
		setBackground(Color.WHITE);
	}
	
	private class CreateListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			System.out.println("Create New Patient was clicked");
			removeAll();
			revalidate();
			repaint();
			add(new CreatePatient());
		}
	}
	private class DeleteListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			System.out.println("Delete a Patient was clicked");
			removeAll();
			revalidate();
			repaint();
			add(new EditPatient());
		}
	}
	private class ViewPatientListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			System.out.println("View Existing Patients was clicked");
			removeAll();
			revalidate();
			repaint();
			add(new CreatePatient());
		}
	}
	private class ViewApptListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			System.out.println("View Appointments was clicked");
			removeAll();
			revalidate();
			repaint();
			add(new ViewAppt());
		}
	}
	private class AddListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			System.out.println("View Appointments was clicked");
			removeAll();
			revalidate();
			repaint();
			add(new AddUser());			
		}
	}
	private class EditListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			System.out.println("View Appointments was clicked");
			removeAll();
			revalidate();
			repaint();
			add(new EditUser());
		}
	}
	private class AccountListener implements ActionListener {
		public void actionPerformed(ActionEvent e) {
			System.out.println("View Appointments was clicked");
			removeAll();
			revalidate();
			repaint();
			add(new AccountLock());
		}
	}
}
